# face detection based on opencv

import cv2

face_patterns = cv2.CascadeClassifier('./frontalface_default.xml')

sample_image = cv2.imread('./test.jpg')

faces = face_patterns.detectMultiScale(sample_image,scaleFactor=1.05,minNeighbors=3,minSize=(100, 100))
print(faces)
for (x, y, w, h) in faces:
    # cv2.rectangle(sample_image, (x, y), (x+w, y+h), (0, 255, 0), 2)
    cv2.rectangle(sample_image, (x, y), (x+w, y+h), (0,0,255), 1)

cv2.imwrite('./rst.jpg', sample_image)
